*&---------------------------------------------------------------------*
*& 包含               YBC_SWS_REPORT_REQ_LOG_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FORM_GET_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM FORM_GET_DATA .
  SELECT *
    INTO TABLE GT_RESULT
    FROM YBC_SWS_REQUEST
   WHERE REQUESTID IN S_REQID
     AND APPID IN S_APPID
     AND BUSINESSID IN S_BUSID
     AND STATUS IN S_STATUS
     AND CDATE IN S_CDATE
     AND CTIME IN S_CTIME.

  IF SY-SUBRC <> 0.
    MESSAGE S002 DISPLAY LIKE 'E'.
    LEAVE LIST-PROCESSING.
  ENDIF.

  SORT GT_RESULT BY REQUESTID DESCENDING.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FORM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM FORM_ALV_DISPLAY .
  DATA:
    LR_DISPLAY   TYPE REF TO CL_SALV_DISPLAY_SETTINGS,
    LR_FUNC_LIST TYPE REF TO CL_SALV_FUNCTIONS_LIST,
    LR_EVENTS    TYPE REF TO CL_SALV_EVENTS_TABLE,
    LR_SELECTS   TYPE REF TO CL_SALV_SELECTIONS,
    LR_COLUMNS   TYPE REF TO CL_SALV_COLUMNS_TABLE,
    LR_COLUMN    TYPE REF TO CL_SALV_COLUMN_TABLE,
    LR_LAYOUT    TYPE REF TO CL_SALV_LAYOUT,
    ST_KEY       TYPE SALV_S_LAYOUT_KEY.

  TRY.
      CL_SALV_TABLE=>FACTORY(
            IMPORTING
              R_SALV_TABLE = GR_TABLE
            CHANGING
              T_TABLE      = GT_RESULT
          ).
    CATCH CX_SALV_MSG.
  ENDTRY.

  "设置列Lable
  LR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
  LR_COLUMNS->SET_OPTIMIZE( 'X' ).
  LR_COLUMNS->SET_KEY_FIXATION( 'X' ).

  "显示设置
  LR_DISPLAY = GR_TABLE->GET_DISPLAY_SETTINGS( ).
  LR_DISPLAY->SET_STRIPED_PATTERN( 'X' ). "设置颜色间隔显示

  "设置选择模式
  LR_SELECTS = GR_TABLE->GET_SELECTIONS( ).
  LR_SELECTS->SET_SELECTION_MODE( CL_SALV_SELECTIONS=>IF_SALV_C_SELECTION_MODE~CELL ).

  "STAUTS ALV 标准功能
*  LR_FUNC_LIST = GR_TABLE->GET_FUNCTIONS( ).
*  LR_FUNC_LIST->SET_ALL( 'X' ).

  "打开Layout保存功能
  LR_LAYOUT = GR_TABLE->GET_LAYOUT( ).
  ST_KEY-REPORT = SY-REPID.
  LR_LAYOUT->SET_KEY( ST_KEY ).
  LR_LAYOUT->SET_DEFAULT( ABAP_TRUE ).
  LR_LAYOUT->SET_SAVE_RESTRICTION( IF_SALV_C_LAYOUT=>RESTRICT_NONE ).

  "设置ALV自定义按钮功能
  GR_TABLE->SET_SCREEN_STATUS(
    PFSTATUS      =  '1000'
     REPORT        =  SY-REPID
     SET_FUNCTIONS = GR_TABLE->C_FUNCTIONS_ALL ).

  "用户自定义按钮事件接受


* Add Hotspot Handlers
  LR_EVENTS = GR_TABLE->GET_EVENT( ).
  CREATE OBJECT GR_EVENTS_HANDLER. "type ref to lcl_events.
  SET HANDLER GR_EVENTS_HANDLER->ON_LINK_CLICK   FOR LR_EVENTS.
  SET HANDLER GR_EVENTS_HANDLER->ON_USER_COMMAND FOR LR_EVENTS.

  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'MANDT' ).
      LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'REQUESTID' ).
      LR_COLUMN->SET_CELL_TYPE( IF_SALV_C_CELL_TYPE=>HOTSPOT ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.


  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'VALUEPART1' ).
      LR_COLUMN->SET_SHORT_TEXT( 'Value1' ).
      LR_COLUMN->SET_MEDIUM_TEXT( 'Para value1' ).
      LR_COLUMN->SET_LONG_TEXT( 'Para value1' ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'VALUEPART2' ).
      LR_COLUMN->SET_SHORT_TEXT( 'Value2' ).
      LR_COLUMN->SET_MEDIUM_TEXT( 'Para value2' ).
      LR_COLUMN->SET_LONG_TEXT( 'Para value2' ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'VALUEPART3' ).
      LR_COLUMN->SET_SHORT_TEXT( 'Value3' ).
      LR_COLUMN->SET_MEDIUM_TEXT( 'Para value3' ).
      LR_COLUMN->SET_LONG_TEXT( 'Para value3' ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'VALUEPART4' ).
      LR_COLUMN->SET_SHORT_TEXT( 'Value4' ).
      LR_COLUMN->SET_MEDIUM_TEXT( 'Para value4' ).
      LR_COLUMN->SET_LONG_TEXT( 'Para value4' ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

  TRY .
      LR_COLUMN  ?= LR_COLUMNS->GET_COLUMN( 'VALUEPART5' ).
      LR_COLUMN->SET_SHORT_TEXT( 'Value5' ).
      LR_COLUMN->SET_MEDIUM_TEXT( 'Para value5' ).
      LR_COLUMN->SET_LONG_TEXT( 'Para value5' ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

  GR_TABLE->DISPLAY( ).
ENDFORM.
